/**
 * @version 1.0
 * @author: jiazhihao
 * @date: 2021-07-07 10:28
 */

import java.util.Scanner;

/**
 * 编写程序：从键盘上输入2019年的“month”和“day”，
 * 要求通过程序 输出输入的日期为2019年的第几天。
 * 说明break在switch-case中是可选的
 */
public class SwitchCaseTest2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入2019年的month");
        int month = scan.nextInt();
        System.out.println("请输入2019年的day");
        int day = scan.nextInt();

        // 定义一个变量来保存总天数
        int sumDays = 0;
        // 方式一：冗余rong yu
         /*if(month == 1) {
             sumDays = day;
         }else if (month == 2) {
             sumDays = 31+day;
         }else if (month == 3) {
             sumDays = 31 + 28 + day;
         }else if (month == 4) {
             .....
         }else if (month == 12) {
             sumDays = ...+day;
         }*/

        //方式二：冗余
        /*switch (month){
            case 1:
                sumDays = day;
                break;
            case 2:
                sumDays =  31+day;
                break;
            case 3:
                sumDays = 31+28+day;
                break;
            case 4:
                sumDays = 31+28+31+day;
                break;
        }*/

        switch (month) {
            case 12:
                sumDays += 30;
            case 11:
                sumDays += 31;
            case 10:
                sumDays += 30;
            case 9:
                sumDays += 31;
            case 8:
                sumDays += 31;
            case 7:
                sumDays += 30;
            case 6:
                sumDays += 31;
            case 5:
                sumDays += 30;
            case 4:
                sumDays += 31;
            case 3:
                sumDays += 28;
            case 2:
                sumDays += 31;
            case 1:
                sumDays += day;
        }
        System.out.println(sumDays);
    }

}
